home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / gs_init.ps < prev    next >
Text File  |  1993-05-29  |  29KB  |  902 lines

  1. %    Copyright (C) 1989, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2. %
  3. % This file is part of Ghostscript.
  4. %
  5. % Ghostscript is distributed in the hope that it will be useful, but
  6. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. % to anyone for the consequences of using it or for whether it serves any
  8. % particular purpose or works at all, unless he says so in writing.  Refer
  9. % to the Ghostscript General Public License for full details.
  10. %
  11. % Everyone is granted permission to copy, modify and redistribute
  12. % Ghostscript, but only under the conditions described in the Ghostscript
  13. % General Public License.  A copy of this license is supposed to have been
  14. % given to you along with Ghostscript so you can know your rights and
  15. % responsibilities.  It should be in a file named COPYING.  Among other
  16. % things, the copyright notice and this notice must be preserved on all
  17. % copies.
  18.  
  19. % Initialization file for the interpreter.
  20. % When this is run, systemdict is still writable.
  21.  
  22. % Comment lines of the form
  23. %    %% Replace <n> <file(s)>
  24. % indicate places where the next <n> lines should be replaced by
  25. % the contents of <file(s)>, when creating a single merged init file.
  26.  
  27. % Check the interpreter revision.  NOTE: the interpreter code requires
  28. % that the first non-comment token in this file be an integer.
  29. 261
  30. dup revision ne
  31.  { (gs: Interpreter revision \() print revision 10 string cvs print
  32.    (\) does not match gs_init.ps revision \() print 10 string cvs print
  33.    (\).\n) print flush 1 .quit
  34.  }
  35. if pop
  36.  
  37. % Define true and false.
  38. systemdict begin
  39. /true 0 0 eq def
  40. /false 0 1 eq def
  41. end
  42.  
  43. % Acquire userdict.
  44. currentdict dup 200 .setmaxlength        % userdict
  45. systemdict begin
  46. /userdict exch def
  47.  
  48. % Acquire the debugging flags.
  49. currentdict /DEBUG known   /DEBUG exch def
  50.   /VMDEBUG
  51.     DEBUG {{print ( ) print vmstatus pop (      ) cvs print pop ( ) print
  52.             systemdict length (      ) cvs print (\n) print flush}}
  53.       {{pop}} ifelse
  54.   def
  55. currentdict /DISKFONTS known   /DISKFONTS exch def
  56. currentdict /ESTACKPRINT known   /ESTACKPRINT exch def
  57. currentdict /NOBIND known   /NOBIND exch def
  58. /.bind /bind load def
  59. NOBIND { /bind { } def } if
  60. currentdict /NOCACHE known   /NOCACHE exch def
  61. currentdict /NODISPLAY known   not /DISPLAYING exch def
  62. currentdict /NOPAUSE known   /NOPAUSE exch def
  63. currentdict /NOPLATFONTS known   /NOPLATFONTS exch def
  64. currentdict /OUTPUTFILE known    % obsolete
  65.  { /OutputFile /OUTPUTFILE load def
  66.    currentdict /OUTPUTFILE undef
  67.  } if
  68. currentdict /QUIET known   /QUIET exch def
  69. currentdict /SAFER known   /SAFER exch def
  70. currentdict /WRITESYSTEMDICT known   /WRITESYSTEMDICT exch def
  71.  
  72. % Acquire environment variables.
  73. currentdict /DEVICE known not
  74.  { (GS_DEVICE) getenv { /DEVICE exch def } if } if
  75.  
  76. QUIET not { (Initializing... ) print flush } if
  77.  
  78. (START) VMDEBUG
  79.  
  80. % Acquire the standard files.
  81. /.stdin (%stdin) (r) file def
  82. /.stdout (%stdout) (w) file def
  83. /.stderr (%stderr) (w) file def
  84.  
  85. % Turn on array packing for the rest of initialization.
  86. true setpacking
  87.  
  88. % Define a procedure for skipping over an unneeded section of code.
  89. % This avoids allocating space for the skipped procedures.
  90. /.skipeof    % string ->
  91.  { { dup currentfile =string readline pop eq { exit } if } loop pop
  92.  } bind def
  93.  
  94. % Define a special version of def for making operator procedures.
  95. /odef
  96.     {1 index exch .makeoperator def} bind def
  97.  
  98. % Define predefined procedures substituting for operators,
  99. % in alphabetical order.
  100.  
  101. userdict /#copies 1 put
  102. /[    /mark load def
  103. /]     {counttomark array astore exch pop} odef
  104. /abs    {dup 0 lt {neg} if} odef
  105. /copypage
  106.     { 1 false .outputpage
  107.       (>>copypage, press <return> to continue<<\n) .confirm
  108.     } odef
  109. /defaultmatrix
  110.     {currentdevice exch deviceinitialmatrix} odef
  111. /.echo /echo load def
  112. userdict /.echo.mode true put
  113. /echo    {dup /.echo.mode exch store .echo} odef
  114. /eexec
  115.     { 55665 .filter_eexecDecode
  116.       cvx systemdict begin stopped
  117.       % Only pop systemdict if it is still the top element,
  118.       % because this is apparently what Adobe interpreters do.
  119.       currentdict systemdict eq { end } if
  120.       { stop } if
  121.     } bind def
  122. /executive
  123.     { { prompt
  124.         { (%statementedit) (r) file } stopped { exit } if
  125.         cvx execute
  126.       } loop
  127.     } odef
  128. /framedevice
  129.     {.stderr (Warning: framedevice is an obsolete operator.\n) writestring
  130.      .stderr flushfile
  131.      pop pop pop setmatrix initclip} odef
  132. /handleerror
  133.     {errordict /handleerror get exec} bind def
  134. /identmatrix
  135.     {{1.0 0.0 0.0 1.0 0.0 0.0} cvlit exch copy} odef
  136. /initgraphics
  137.     {initmatrix newpath initclip 1 setlinewidth 0 setlinecap 0 setlinejoin
  138.      [] 0 setdash 0 setgray 10 setmiterlimit} odef
  139. /initmatrix
  140.     {.tempmatrix defaultmatrix setmatrix} odef
  141. /languagelevel 1 def        % we don't have full Level 2
  142. /matrix    {6 array identmatrix} odef
  143. /prompt    {flush flushpage
  144.      (GS) print count 0 ne
  145.       {(<) print count =only}
  146.      if (>) print flush} bind def
  147. /pstack    {0 1 count 3 sub {index ==} for} def
  148. /quit    {0 .quit} odef
  149. /run    {dup type /filetype eq
  150.       { true }
  151.       { findlibfile { exch pop true } { false } ifelse }
  152.      ifelse
  153.       {cvx execute}
  154.       {(r) file}        % let the error happen
  155.      ifelse} odef
  156. /showpage
  157.     { #copies true .outputpage
  158.       (>>showpage, press <return> to continue<<\n) .confirm
  159.       erasepage initgraphics
  160.     } odef
  161. % Code output by Adobe Illustrator relies on the fact that
  162. % `stack' is a procedure, not an operator!!!
  163. /stack    {0 1 count 3 sub {index =} for} bind def
  164. /start    { executive } def
  165. % This interpreter is compatible with PostScript "version" 54.0 (I think).
  166. /version (54.0) def
  167.  
  168. % Provide semi-fake but usable definitions for some of
  169. % the color PostScript extensions.
  170. /setcolorscreen {
  171.     setscreen 9 {pop} repeat
  172. } odef
  173. /currentcolorscreen {
  174.     currentscreen 3 copy 6 copy
  175. } odef
  176.  
  177. % Define some additional built-in procedures (beyond the ones defined by
  178. % the PostScript Language Reference Manual).
  179. % Warning: these are not guaranteed to stay the same from one Ghostscript
  180. % release to the next!
  181.  
  182. /concatstrings
  183.     { exch dup length 2 index length add string    % str2 str1 new
  184.       dup dup 4 2 roll copy        % str2 new new new1
  185.       length 4 -1 roll putinterval
  186.     } bind def
  187. /copyarray
  188.     { dup length array copy } bind def
  189. /copystring
  190.     { dup length string copy } bind def
  191. /.dicttomark        % (the Level 2 >> operator)
  192.     { counttomark 2 idiv dup dict begin
  193.        { def } repeat pop currentdict end
  194.     } bind def
  195. /finddevice
  196.     { systemdict /devicedict get exch get } bind def
  197. /.growdict        % grow a dictionary
  198.     { dup length 3 mul 2 idiv 1 add .setmaxlength
  199.     } bind def
  200. /.growput        % put, grow the dictionary if needed
  201.     { 2 index length 3 index maxlength eq
  202.        { 3 copy pop known not { 2 index .growdict } if
  203.        } if
  204.       put
  205.     } bind def
  206. /selectdevice
  207.     { finddevice setdevice } bind def
  208. /signalerror        % object errorname
  209.     { errordict exch get exec } bind def
  210.  
  211. % Define =string, which is used by some PostScript programs even though
  212. % it isn't documented anywhere.
  213. /=string 128 string def
  214.  
  215. % Define the =[only] procedures.  Also define =print,
  216. % which is used by some PostScript programs even though
  217. % it isn't documented anywhere.
  218. /=    { =only (\n) print } bind def
  219. /=only    { { =string cvs } stopped { pop pop (--nostringval--) } if print } bind def
  220. /=print    /=only load def
  221. % Temporarily define == as = for the sake of run0.
  222. /== /= load def
  223.  
  224. % Define the filter operator.
  225.  
  226. /.filterstring (.filter_01234567890123456789) def
  227. /.filterstring1 .filterstring 8 .filterstring length 8 sub getinterval def
  228. /filter
  229.     { //.filterstring exch 0 exch
  230.       //.filterstring1 cvs length 8 add getinterval cvn load exec
  231.     } odef
  232. systemdict /.filter_LZWEncode undef    % per FSF
  233.  
  234. % Define procedures for getting and setting the current device resolution.
  235.  
  236. /gsgetdeviceprop
  237.  { 1 index getdeviceprops
  238.     { 1 index counttomark 1 add index eq { exit } if pop pop } loop
  239.    dup mark eq        % if true, not found
  240.     { pop dup /undefined signalerror }
  241.     { counttomark 1 add 1 roll cleartomark exch pop exch pop }
  242.    ifelse
  243.  } bind def
  244. /gscurrentresolution
  245.  { currentdevice /HWResolution gsgetdeviceprop
  246.  } bind def
  247. /gssetresolution
  248.  { 2 array astore mark exch /HWResolution exch
  249.    currentdevice copydevice putdeviceprops setdevice
  250.  } bind def
  251.  
  252. % Define auxiliary procedures needed for the above.
  253. /shellarguments        % -> shell_arguments true (or) false
  254.     { /ARGUMENTS where
  255.        { /ARGUMENTS get dup type /arraytype eq
  256.           { aload pop /ARGUMENTS null store true }
  257.           { pop false }
  258.          ifelse }
  259.        { false } ifelse
  260.     } bind def
  261. /.confirm
  262.     {DISPLAYING NOPAUSE not and
  263.       {% Print a message and wait for the user to type something.
  264.        % If the user just types a newline, flush it.
  265.        print flush
  266.        .echo.mode false echo
  267.          .stdin dup read
  268.          {dup (\n) 0 get eq {pop pop} {unread} ifelse} {pop} ifelse
  269.        echo}
  270.       {pop} ifelse} bind def
  271. /.identmatrix        % a read-only identity matrix
  272.     matrix readonly def
  273. /.tempmatrix        % a temporary matrix
  274.     matrix def
  275.  
  276. % Define the procedure used by the C executive for executing user input,
  277. % and also by the run operator.
  278. % This is called with a procedure or file on the operand stack.
  279. /execute
  280.     {stopped $error /newerror get and {handleerror} if} odef
  281. % Define an execute analogue of run0.
  282. /execute0
  283.     {stopped $error /newerror get and {handleerror flush 1 .quit} if} bind def
  284.  
  285. % Define a special version of `run' that aborts on errors.
  286. /run0
  287.     { dup /.currentfilename exch def
  288.        { findlibfile not { stop } if }
  289.       stopped
  290.        { (Can't find initialization file ) print
  291.          .currentfilename == flush 1 .quit
  292.        } if
  293.       exch pop cvx stopped
  294.        { (While reading ) print .currentfilename print (:\n) print flush
  295.          handleerror 1 .quit
  296.        } if
  297.     } bind def
  298. % Temporarily substitute it for the real `run'.
  299. /.run /run load def
  300. /run /run0 load def
  301.  
  302. % If we want a "safer" system, disable some obvious ways to cause havoc.
  303. SAFER not { (%END SAFER) .skipeof } if
  304. /file
  305.  { dup (r) eq
  306.     { file }
  307.     { /invalidfileaccess signalerror }
  308.    ifelse
  309.  } bind odef
  310. /renamefile { /invalidfileaccess signalerror } odef
  311. /deletefile { /invalidfileaccess signalerror } odef
  312. %END SAFER
  313.  
  314. % Create the error handling machinery.
  315. % The interpreter has created the ErrorNames array.
  316. % Define $error.
  317. /$error 11 dict def        % newerror, errorname, command, errorinfo,
  318.                 % ostack, estack, dstack, recordstacks,
  319.                 % binary, .inerror, position
  320. $error begin
  321.   /newerror false def
  322.   /recordstacks true def
  323.   /binary false def
  324.   /.inerror false def
  325.   /position null def
  326. end
  327. % Define errordict.  It has one entry per error name,
  328. %   plus handleerror and .printerror.
  329. /errordict ErrorNames length 2 add dict def
  330. % Define the standard error handlers.  When they are invoked,
  331. % the top element of the o-stack is the error name;
  332. % the next element is the offending command.
  333. errordict begin
  334.   { //$error /.inerror get .instopped not or
  335.      { (Unrecoverable error: ) print =only flush
  336.        ( in ) print = flush
  337.        count 0 gt
  338.         { (Operand stack:\n  ) print
  339.       0 1 count 3 sub { (  ) print index =only flush } for
  340.       (\n) print flush
  341.     } if
  342.        1 .quit
  343.      } if    % detect error recursion
  344.     $error /.inerror true put
  345.     $error /newerror true put
  346.     $error exch /errorname exch put
  347.     $error exch /command exch put
  348.     $error /dstack undef
  349.     $error /estack undef
  350.     $error /ostack undef
  351.     $error /recordstacks get $error /errorname get /VMerror ne and
  352.      { $error /dstack countdictstack array dictstack put
  353.        $error /estack countexecstack array execstack put
  354.        count array astore dup $error exch /ostack exch put
  355.      aload pop
  356.      } if
  357.     $error /position currentfile status
  358.      { errordict /ioerror get
  359.        errordict /ioerror { pop stop } put
  360.        currentfile { fileposition } stopped { pop null } if
  361.        errordict /ioerror 4 -1 roll put
  362.      }
  363.      { null
  364.      }
  365.     ifelse put
  366.     $error /.inerror false put
  367.     stop
  368.   } bind
  369.   ErrorNames
  370.    { [ 1 index 3 index /exec load ] cvx def
  371.    } forall
  372.   pop
  373. end
  374. % Define the standard handleerror.  We break out the printing procedure
  375. % (.printerror) so that it can be extended for binary output
  376. % if the Level 2 facilities are present.
  377. errordict begin
  378.   /.printerror
  379.    { (Error: ) print
  380.      $error begin
  381.        errorname ==only flush
  382.        ( in ) print
  383.        /command load ==only flush
  384.        currentdict /ostack known
  385.         { (\nOperand stack:\n  ) print ostack { (  ) print ==only } forall
  386.     } if
  387.        currentdict /estack known
  388.         { (\nExecution stack:\n  ) print
  389.       estack { (  ) print ESTACKPRINT { ==only } { =only } ifelse } forall
  390.     } if
  391.        currentdict /dstack known
  392.     { (\nDictionary stack:\n  ) print dstack
  393.        { dup (  ) print length =only (/) print maxlength =only } forall
  394.     } if
  395.        (\n) print
  396.        errorname /VMerror eq
  397.         { (VM status:) print mark vmstatus
  398.       counttomark { ( ) print counttomark -1 roll dup =only } repeat
  399.       cleartomark (\n) print
  400.     } if
  401.        position null ne
  402.     { (Current file position is ) print position = }
  403.        if
  404.        /newerror false def
  405.      end
  406.      flush
  407.    } bind def
  408.   /handleerror
  409.    { errordict /.printerror get exec
  410.      .instopped {stop} if
  411.    } bind def
  412. end
  413.  
  414. % Define the [write]==[only] procedures.
  415. /==    {==only (\n) print} bind def
  416. /==only    {.stdout exch write==only} bind def
  417. /write==
  418.     {2 copy write==only pop (\n) writestring} bind def
  419. /.dict 16 dict dup
  420. begin def
  421.   /.cvp {=string cvs .p} bind def
  422. % /.f {the_output_file} def
  423.   /.nop {(-) .p type .cvp (-) .p} bind def
  424.   /.p {.f exch writestring} bind def
  425.   /.print
  426.     {dup type .dict exch known
  427.      {dup type exec} {.nop} ifelse
  428.     } bind def
  429.   /integertype /.cvp load def
  430.   /nulltype { pop (null) .p } bind def
  431.   /realtype /.cvp load def
  432.   /booleantype /.cvp load def
  433.   /nametype
  434.     {dup xcheck not {(/) .p} if
  435.      dup length =string length gt
  436.       {dup length string}
  437.       {=string}
  438.      ifelse cvs .p} bind def
  439.   /arraytype
  440.     {dup rcheck
  441.       {dup xcheck {(})({)} {(])([)} ifelse .p
  442.        exch () exch
  443.        {exch .p .print ( )} forall pop .p}
  444.       {.nop}
  445.      ifelse} bind def
  446.   /operatortype
  447.       {(--) .p .cvp (--) .p} bind def
  448.   /packedarraytype /arraytype load def
  449. % /.ch {a_character} def
  450.   /stringtype
  451.     {dup rcheck
  452.       {(\() .p
  453.        {dup dup 32 lt exch 127 ge or
  454.         {(\\) .p 8#1000 add 8 =string cvrs 1 3 getinterval .p}
  455.         {dup dup -2 and 40 eq exch 92 eq or {(\\) .p} if
  456.          .f exch write}
  457.         ifelse}
  458.        forall (\)) .p}
  459.       {.nop}
  460.      ifelse} bind def
  461. {//.dict begin exch cvlit /.f exch def .print end}
  462.   bind cvx
  463. end
  464. /write==only exch def
  465.  
  466. (END PROCS) VMDEBUG
  467.  
  468. % Define the font directory.
  469. % Make it big to leave room for transformed fonts.
  470. /FontDirectory 100 dict def
  471.  
  472. % Define the standard encoding vector.
  473. /StandardEncoding
  474. % \00x
  475.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  476.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  477.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  478.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  479. % \04x
  480.     /space /exclam /quotedbl /numbersign
  481.     /dollar /percent /ampersand /quoteright
  482.     /parenleft /parenright /asterisk /plus
  483.     /comma /hyphen /period /slash
  484.     /zero /one /two /three
  485.     /four /five /six /seven
  486.     /eight /nine /colon /semicolon
  487.     /less /equal /greater /question
  488. % \10x
  489.     /at /A /B /C /D /E /F /G
  490.     /H /I /J /K /L /M /N /O
  491.     /P /Q /R /S /T /U /V /W
  492.     /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
  493. % \14x
  494.     /quoteleft /a /b /c /d /e /f /g
  495.     /h /i /j /k /l /m /n /o
  496.     /p /q /r /s /t /u /v /w
  497.     /x /y /z /braceleft /bar /braceright /asciitilde /.notdef
  498. % \20x
  499.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  500.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  501.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  502.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  503. % \24x
  504.     /.notdef /exclamdown /cent /sterling
  505.     /fraction /yen /florin /section
  506.     /currency /quotesingle /quotedblleft /guillemotleft
  507.     /guilsinglleft /guilsinglright /fi /fl
  508.     /.notdef /endash /dagger /daggerdbl
  509.     /periodcentered /.notdef /paragraph /bullet
  510.     /quotesinglbase /quotedblbase /quotedblright /guillemotright
  511.     /ellipsis /perthousand /.notdef /questiondown
  512. % \30x
  513.     /.notdef /grave /acute /circumflex /tilde /macron /breve /dotaccent
  514.     /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
  515.     /emdash /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  516.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  517. % \34x
  518.     /.notdef /AE /.notdef /ordfeminine /.notdef /.notdef /.notdef /.notdef
  519.     /Lslash /Oslash /OE /ordmasculine /.notdef /.notdef /.notdef /.notdef
  520.     /.notdef /ae /.notdef /.notdef /.notdef /dotlessi /.notdef /.notdef
  521.     /lslash /oslash /oe /germandbls /.notdef /.notdef /.notdef /.notdef
  522. 256 packedarray def
  523. 0 StandardEncoding .registerencoding
  524.  
  525. % Define the ISO Latin-1 encoding vector.
  526. % The first half is the same as the standard encoding,
  527. % except for minus instead of hyphen at code 055.
  528. /ISOLatin1Encoding
  529. StandardEncoding 0 45 getinterval aload pop
  530.     /minus
  531. StandardEncoding 46 82 getinterval aload pop
  532. %*** NOTE: the following are missing in the Adobe documentation,
  533. %*** but appear in the displayed table:
  534. %*** macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240.
  535. % \20x
  536.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  537.     /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  538.     /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
  539.     /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
  540. % \24x
  541.     /space /exclamdown /cent /sterling
  542.     /currency /yen /brokenbar /section
  543.     /dieresis /copyright /ordfeminine /guillemotleft
  544.     /logicalnot /hyphen /registered /macron
  545.     /degree /plusminus /twosuperior /threesuperior
  546.     /acute /mu /paragraph /periodcentered
  547.     /cedilla /onesuperior /ordmasculine /guillemotright
  548.     /onequarter /onehalf /threequarters /questiondown
  549. % \30x
  550.     /Agrave /Aacute /Acircumflex /Atilde
  551.     /Adieresis /Aring /AE /Ccedilla
  552.     /Egrave /Eacute /Ecircumflex /Edieresis
  553.     /Igrave /Iacute /Icircumflex /Idieresis
  554.     /Eth /Ntilde /Ograve /Oacute
  555.     /Ocircumflex /Otilde /Odieresis /multiply
  556.     /Oslash /Ugrave /Uacute /Ucircumflex
  557.     /Udieresis /Yacute /Thorn /germandbls
  558. % \34x
  559.     /agrave /aacute /acircumflex /atilde
  560.     /adieresis /aring /ae /ccedilla
  561.     /egrave /eacute /ecircumflex /edieresis
  562.     /igrave /iacute /icircumflex /idieresis
  563.     /eth /ntilde /ograve /oacute
  564.     /ocircumflex /otilde /odieresis /divide
  565.     /oslash /ugrave /uacute /ucircumflex
  566.     /udieresis /yacute /thorn /ydieresis
  567. 256 packedarray def
  568. 1 ISOLatin1Encoding .registerencoding
  569.  
  570. % Define stubs for the Symbol and Dingbats encodings.
  571. userdict begin
  572. %% Replace 3 (gs_sym_e.ps)
  573.   /SymbolEncoding
  574.    { userdict begin (gs_sym_e.ps) run /SymbolEncoding load end
  575.    } bind def
  576. %% Replace 3 (gs_dbt_e.ps)
  577.   /DingbatsEncoding
  578.    { userdict begin (gs_dbt_e.ps) run /DingbatsEncoding load end
  579.    } bind def
  580. end
  581.  
  582. (END FONTDIR/ENCS) VMDEBUG
  583.  
  584. % Construct a dictionary of all available devices.
  585. mark
  586.     % Loop until the getdevice gets a rangecheck.
  587.   0 { {dup getdevice exch 1 add} loop} stopped pop
  588.   dict /devicedict exch def
  589.   devicedict begin        % 2nd copy of count is on stack
  590.    { dup /Name gsgetdeviceprop cvn dup 3 -1 roll def
  591.      counttomark 1 roll
  592.    } repeat
  593.   end
  594. ] /devicenames exch def
  595. $error /newerror false put        % remove error indication
  596.  
  597. (END DEVS) VMDEBUG
  598.  
  599. % Define statusdict, for the benefit of programs
  600. % that think they are running on a LaserWriter or similar printer.
  601. %% Replace 1 (gs_statd.ps)
  602. (gs_statd.ps) run
  603.  
  604. (END STATD) VMDEBUG
  605.  
  606. % Load the standard font environment.
  607. %% Replace 1 (gs_fonts.ps)
  608. (gs_fonts.ps) run
  609.  
  610. (END GS_FONTS) VMDEBUG
  611.  
  612. % Load the initialization files for optional features.
  613. %% Replace 4 INITFILES
  614. systemdict /INITFILES known
  615.  { INITFILES { dup run VMDEBUG } forall
  616.  }
  617. if
  618.  
  619. % If Level 2 functionality is implemented, enable it now.
  620. /.setlanguagelevel where { pop 2 .setlanguagelevel } if
  621.  
  622. % Create a null font.  This is the initial font.
  623. 8 dict dup begin
  624.   /FontMatrix [ 1 0 0 1 0 0 ] def
  625.   /FontType 3 def
  626.   /FontName () def
  627.   /Encoding StandardEncoding def
  628.   /FontBBox { 0 0 0 0 } def    % executable is bogus, but customary ...
  629.   /BuildChar { pop pop 0 0 setcharwidth } bind def
  630.   /PaintType 0 def        % shouldn't be needed!
  631. end
  632. /NullFont exch definefont setfont
  633. % Define NullFont as the font, but remove it from FontDirectory.
  634. /NullFont currentfont def
  635. FontDirectory /NullFont undef
  636.  
  637. (END FONTS) VMDEBUG
  638.  
  639. % Restore the real definition of run.
  640. /run /.run load def
  641. currentdict /.run undef
  642.  
  643. % Bind all the operators defined as procedures.
  644. /.bindoperators        % binds operators in currentdict
  645.  { % Temporarily disable the typecheck error.
  646.    errordict /typecheck errordict /typecheck get
  647.    errordict /typecheck { pop } put    % pop the command
  648.    currentdict
  649.     { dup type /operatortype eq
  650.        { % This might be a real operator, so bind might cause a typecheck,
  651.      % but we've made the error a no-op temporarily.
  652.      .bind        % do a real bind even if NOBIND is set
  653.        }
  654.       if pop pop
  655.     } forall
  656.    put
  657.  } def
  658. NOBIND not { .bindoperators } if
  659.  
  660. % Establish a default environment.
  661.      
  662. DISPLAYING not
  663.  { nulldevice (%END DISPLAYING) .skipeof
  664.  } if
  665. /defaultdevice 0 getdevice systemdict /DEVICE known
  666.  { pop devicedict DEVICE known not
  667.     { (Unknown device: ) print DEVICE =
  668.       flush 1 .quit
  669.     }
  670.    if DEVICE finddevice
  671.  }
  672. if def
  673. defaultdevice
  674. systemdict /DEVICEWIDTH known
  675. systemdict /DEVICEHEIGHT known or
  676. systemdict /DEVICEWIDTHPOINTS known or
  677. systemdict /DEVICEHEIGHTPOINTS known or
  678. systemdict /DEVICEXRESOLUTION known or
  679. systemdict /DEVICEYRESOLUTION known or
  680. systemdict /PAPERSIZE known or
  681. not { (%END DEVICE) .skipeof } if
  682. systemdict /PAPERSIZE known
  683.  {    % Convert the paper size to device dimensions.
  684.    true statusdict /.pagetypenames get
  685.     { PAPERSIZE eq
  686.        { PAPERSIZE load
  687.          dup 0 get /DEVICEWIDTHPOINTS exch def
  688.          1 get /DEVICEHEIGHTPOINTS exch def
  689.          pop false exit
  690.        }
  691.       if
  692.     }
  693.    forall
  694.     { (Unknown paper size: ) print PAPERSIZE ==only (.\n) print
  695.     }
  696.    if
  697.  }
  698. if
  699. % Adjust the device parameters per the command line.
  700.    getdeviceprops .dicttomark begin
  701.    6 dict begin
  702.    /dw HWSize 0 get def
  703.    /dh HWSize 1 get def
  704.    /dmat InitialMatrix def
  705.    /dxres HWResolution 0 get def
  706.    /dyres HWResolution 1 get def
  707.    /DEVICEXRESOLUTION where
  708.     { pop /drq DEVICEXRESOLUTION dxres div def
  709.       0 2 4
  710.        { dup
  711.      dmat exch get drq mul
  712.      dmat 3 1 roll put
  713.        }
  714.       for
  715.       dw drq mul round cvi /dw exch def
  716.       /dxres DEVICEXRESOLUTION def
  717.     }
  718.    if
  719.    /DEVICEYRESOLUTION where
  720.     { pop /drq DEVICEYRESOLUTION dyres div def
  721.       1 2 5
  722.        { dup
  723.          dmat exch get drq mul
  724.      dmat 3 1 roll put
  725.        }
  726.       for
  727.       dh drq mul round cvi /dh exch def
  728.       /dyres DEVICEYRESOLUTION def
  729.      }
  730.    if
  731.     % Check for device sizes specified in pixels.
  732.    /DEVICEWIDTH where
  733.     { pop /dw DEVICEWIDTH def
  734.     }
  735.    if
  736.    /DEVICEHEIGHT where
  737.     { pop /dh DEVICEHEIGHT def
  738.     }
  739.    if
  740.     % Check for device sizes specified in points.
  741.    /DEVICEWIDTHPOINTS where
  742.     { pop /dw DEVICEWIDTHPOINTS dxres mul 72 div round cvi def
  743.     }
  744.    if
  745.    /DEVICEHEIGHTPOINTS where
  746.     { pop /dh DEVICEHEIGHTPOINTS dyres mul 72 div round cvi def
  747.     }
  748.    if
  749.    mark
  750.    /HWSize [ dw dh ] /HWResolution [ dxres dyres ] /InitialMatrix dmat
  751.    defaultdevice putdeviceprops
  752.    end end
  753. %END DEVICE
  754. % Set any device properties defined on the command line.
  755. dup getdeviceprops
  756. counttomark 2 idiv
  757.  { systemdict 2 index known
  758.     { pop dup load counttomark 2 roll }
  759.     { pop pop }
  760.    ifelse
  761.  } repeat
  762. systemdict /BufferSpace known
  763. systemdict /MaxBitmap known not and
  764.  { /MaxBitmap BufferSpace
  765.  } if
  766. counttomark dup 0 ne
  767.  { 2 add -1 roll putdeviceprops }
  768.  { pop pop }
  769. ifelse
  770. setdevice        % does an erasepage
  771. %END DISPLAYING
  772.  
  773. % Set the graphics state parameters that initgraphics doesn't initialize.
  774. 1 setflat
  775. { } setblackgeneration
  776. { pop 0 } setundercolorremoval
  777.  
  778. (END DEVICE) VMDEBUG
  779.  
  780. % Establish a default upper limit in the character cache,
  781. % namely, enough room for a 1/4" x 1/4" character at the resolution
  782. % of the default device, or for 3 x the "average" character size,
  783. % whichever is larger.
  784. mark
  785.     % Compute limit based on character size.
  786.   18 18 dtransform        % 1/4" x 1/4"
  787.   exch abs cvi 31 add 32 idiv 4 mul    % X raster
  788.   exch abs cvi mul        % Y
  789.     % Compute limit based on allocated space.
  790.   cachestatus 5 2 roll pop pop pop pop div 3 mul cvi exch pop
  791.   max dup 10 idiv exch
  792. setcacheparams
  793. % Conditionally disable the character cache.
  794. NOCACHE { 1 setcachelimit } if
  795.  
  796. (END CONFIG) VMDEBUG
  797.  
  798. % Establish an appropriate halftone screen.
  799.  
  800. 72 72 dtransform abs exch abs min    % min(|dpi x|,|dpi y|)
  801. dup 150 lt systemdict /DITHERPPI known not and
  802.  {        % Low-res device, use ordered dither spot function
  803.     % The following 'ordered dither' spot function was contributed by
  804.     % Gregg Townsend.  Thanks, Gregg!
  805.   16.001 div 0            % not 16: avoids rounding problems
  806.    { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
  807.     0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
  808.     CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
  809.     3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
  810.     FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
  811.     01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
  812.     C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
  813.     31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
  814.     F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
  815.     0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
  816.     CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
  817.     3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
  818.     FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
  819.     02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
  820.     C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
  821.     32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
  822.     F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
  823.    > exch get 256 div }        % screen
  824.   { }        % transfer
  825.   true        % strokeadjust
  826.  }
  827.  {        % Hi-res device, use 45 degree dot spot function.
  828.     % 46 seems to be a good frequency value for printers
  829.     % between 200 and 400 DPI.  We set the frequency low enough
  830.     % that we can be guaranteed at least a 4x4 pixel cell.
  831.    systemdict /DITHERPPI known { DITHERPPI } { 46 } ifelse
  832.    exch 4.01 div min
  833.    45
  834.     % The following screen algorithm is used by permission of the author.
  835.     { 1 add 180 mul cos 1 0.08 add mul exch 2 add 180 mul cos 
  836.       1 0.08 sub mul add 2 div % (C) 1989 Berthold K.P. Horn
  837.     }        % screen
  838.     % Set the transfer function to lighten up the grays.
  839.     % We correct at the high end so that very light grays
  840.     % don't disappear completely if they darken <1 screen pixel.
  841.    { sqrt dup dup 0.9375 gt exch 0.995 lt and    % > 15/16
  842.       { currentscreen pop pop
  843.         gsave initmatrix 72 exch div dup dtransform grestore
  844.     cvi exch cvi mul abs        % # of pixels in halftone cell
  845.     1 sub                % tweak to avoid boundary
  846.     1 exch div 1 exch sub min
  847.       }
  848.      if
  849.    }
  850.    false    % strokeadjust
  851.  }
  852. ifelse
  853.   5 -3 roll bind setscreen
  854.   exch settransfer
  855.   /setstrokeadjust where { pop setstrokeadjust } { pop } ifelse
  856. initgraphics
  857. % The interpreter relies on there being at least 2 entries
  858. % on the graphics stack.  Establish the second one now.
  859. gsave
  860.  
  861. % Define some control sequences as no-ops.
  862. % This is a hack to get around problems
  863. % in some common PostScript-generating applications.
  864. (\004) cvn { } def        % Apple job separator
  865. (\004\004) cvn { } def        % two of the same
  866. (\033) cvn { } def        % MS Windows LaserJet IV prologue
  867. (\004\033) cvn { } def        % MS Windows LaserJet IV epilogue
  868.  
  869. % Turn off array packing for interactive use.
  870. false setpacking
  871.  
  872. % Close up systemdict.
  873. end
  874. WRITESYSTEMDICT not { systemdict readonly pop } if
  875.  
  876. (END INIT) VMDEBUG
  877.  
  878. % Print the welcome message.
  879.  
  880. QUIET { (%END WELCOME) .skipeof } if
  881.  
  882. (done.\n) print flush
  883.  
  884. product print
  885. ( ) print revision 10 idiv 10 div =only
  886. revision 10 mod (.) print =only
  887. ( \() print revisiondate 100 idiv 100 mod =only
  888. (/) print revisiondate 100 mod =only
  889. (/) print revisiondate 10000 idiv =only
  890. (\)\n) print copyright print
  891. (  All rights reserved.\n) print
  892. product (Ghostscript) eq
  893.  { (Ghostscript comes with NO WARRANTY: see the file COPYING for details.\n) print
  894.  }
  895. if
  896.  
  897. flush
  898.  
  899. %END WELCOME
  900.  
  901. % The interpreter will run the initial procedure (start).
  902.